package at.spengergasse.web.servlet.kunden;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import at.spengergasse.model.Kunden;
import at.spengergasse.web.EntryPointURLEnum;
import at.spengergasse.web.ViewEnum;

@SuppressWarnings("serial")
public class RegistrationServlet extends AbstractKundenServlet
{

	public RegistrationServlet() throws Exception
	{
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		setupFormData(req);
		req.getRequestDispatcher(ViewEnum.KUNDEN_ADD.getView()).forward(req,
				resp);

	}

	private void setupFormData(HttpServletRequest req)
	{
		req.setAttribute("title", "Registrierung eines neuen Kunden");
		req.setAttribute("actionURL", EntryPointURLEnum.KUNDEN_ADD.getUrl());
		req.setAttribute("Kunde", new Kunden("Mustermann@test.at", "Herr",
				"Mustermann", "Passwort", "Musterstrasse"));

		// only for access to constants via JSTL

		req.setAttribute("kundenFields", new KundenFieldNames());

	}

}
